<?php 
$username = "username";
$email  = "email";
$emailconfirm = "emailconfirm";
$comment = "comment";
$recommend = "recommend";
require 'header.php';

session_start();

if(isset($_SESSION['views']))
$_SESSION['views']=$_SESSION['views']+1;
else
$_SESSION['views']=1;
?>

  <!-- Form  -->
  <div id="form">
  <form name = "form" action = "formindex.php" method="POST" enctype="multipart/form-data">
  <!-- Username  -->
	<p>
	<?php report_if_error("username_error"); ?>
	Name <span class="notbold">(letters and numbers only)</span>:
	<br><input type="text" name="username" <?php echo_value_if_set("username"); ?>  required>
	</p>
  <!-- Email  -->
	<p>
	<?php report_if_error("email_error"); ?>
	Email <span class="notbold">(Enter twice to check for validity)</span>:<br>
	<input type="text" name="email" <?php echo_value_if_set("email"); ?> required>
	<input type="text" name="emailconfirm" <?php echo_value_if_set("emailconfirm"); ?> required>
	</p>
  <!-- Post Comment  -->
	<p>
	<?php report_if_error("comment_error"); ?>
	Post Comment, Questions, etc.:<br>
	<textarea name="comment" rows=10 cols=50 maxlength="500"
	required><?php if ( isset($_POST['comment'])){echo $_POST['comment'];}?></textarea>
	</p>
  <!-- Recommend  -->
	<p>
	<?php report_if_error("recommend_error"); ?>
	Would You Recommend The Hot Truck to a Friend?:<br>
	<input type='radio' name='recommend' value='Unknown' checked>No Opinion
	<input type='radio' name='recommend' value='Yes'>Yes
	<input type='radio' name='recommend' value='No'>No	
	</p>
	
	<?php $date=date('M j, Y')?>
	
    <p><input type="submit" name='submission' value="Post to Wall"><br>
	<input type="reset" value="Reset"	>
	</p>
  </form>
  </div>
    
<?php 
require 'footer.php';
?>

<?php
// A helper function to print an error, if it exists.
function report_if_error($error_name) {
  if ( isset($_POST[$error_name]) ) {
    echo "<span class=\"errormsg\">" . $_POST[$error_name] . "</span>";
  }
}

// A helper function that echoes ' value="something" ' if there
// is something set in the specified field name.
function echo_value_if_set($field_name) {
  if ( isset($_POST[$field_name]) ) { 
    echo " value=\"" . $_POST[$field_name] . "\" "; 
  }
}
?>